import { defHttp } from '@/utils/http/axios';
import { AddCompanyCategory, AddCompanyTypeGroup, CompanyCategory, CompanyTypeGroup, EditCompanyCategory, EditCompanyTypeGroup, UpdCompanyDisable } from './type';
import { OrgInitEnum } from '@/enums/publicEnum';



enum Api {
    getCompanyCategoryList = '/admin/custom/company/type/list',
    addCompanyCategory = '/admin/custom/company/type/add',
    editCompanyCategory = '/admin/custom/company/type/update',
    updCompanyDisable = '/admin/custom/company/type/disable/set',
    updCompanyOrgInit = '/admin/custom/company/type/init/set',
    delCompanyCategory = '/admin/custom/company/type/del',

    getCompanyCategoryGroupList = '/admin/custom/company/type/group/list',
    addCompanyCategoryGroup = '/admin/custom/company/type/group/add',
    editCompanyCategoryGroup = '/admin/custom/company/type/group/update',
    delCompanyCategoryGroup = '/admin/custom/company/type/group/delete'
}

/**
 * @description 查询单位类别列表
 * @date
 * @export
 * @param
 */
export function getCompanyCategoryList(params: any) {
    return defHttp.get<CompanyCategory[]>({
        url: Api.getCompanyCategoryList,
        params
    });
}

/**
 * 新增单位类别
 * @param data 
 * @returns 
 */
export function addCompanyCategory(data: AddCompanyCategory) {
    return defHttp.post({
        url: Api.addCompanyCategory,
        data
    });
}

/**
 * 修改单位类别
 * @param data 
 * @returns 
 */
export function editCompanyCategory(data: EditCompanyCategory) {
    return defHttp.post({
        url: Api.editCompanyCategory,
        data
    });
}

/**
 * 禁用启用单位类别
 * @param data 
 * @returns 
 */
export function updCompanyDisable(data: UpdCompanyDisable) {
    return defHttp.post({ url: `${Api.updCompanyDisable}`, data });
}

/**
 * 修改单位初始化值
 * @param data 
 * @returns 
 */
export function updCompanyOrgInit(data: { id: number, orgInit: OrgInitEnum }) {
    return defHttp.post({ url: `${Api.updCompanyOrgInit}`, data });
}

/**
 * 删除单位类别
 * @param groupId 
 * @returns 
 */
export function delCompanyCategory(id: number) {
    return defHttp.post({ url: Api.delCompanyCategory + '/' + id });
}

/**
 * @description 查询单位类别分组列表
 * @date
 * @export
 * @param
 */
export function getCompanyCategoryGroupList(params: any) {
    return defHttp.get<CompanyTypeGroup[]>({
        url: Api.getCompanyCategoryGroupList,
        params
    });
}

/**
 * 新增单位类别分组
 * @param data 
 * @returns 
 */
export function addCompanyCategoryGroup(data: AddCompanyTypeGroup) {
    return defHttp.post({
        url: Api.addCompanyCategoryGroup,
        data
    });
}

/**
 * 修改单位类别分组
 * @param data 
 * @returns 
 */
export function editCompanyCategoryGroup(data: EditCompanyTypeGroup) {
    return defHttp.post({
        url: Api.editCompanyCategoryGroup,
        data
    });
}

/**
 * 删除单位类别分组
 * @param data 
 * @returns 
 */
export function delCompanyCategoryGroup(groupId: number) {
    return defHttp.post({ url: Api.delCompanyCategoryGroup, data: { groupId } });
}